<?php

/**
 * uniBoard Forum Application Controller
 *
 * Light and fast forum solution for web 2.0-like communities.
 *
 * @package		uniBoard
 * @author		Rafał Pitoń
 * @license		http://www.gnu.org/licenses/gpl-3.0.html
 * @since		Version 0.1
 * 
 * ------------------------------------------------------------------------
 * 
 * $Date: 2010-09-20 21:23:27 +0000 (Mon, 20 Sep 2010) $
 * $Revision: 64 $
 * $Author: rafio.xudb@gmail.com $
 */

// ------------------------------------------------------------------------

class app_forum{
	
	/**
	 * Main class pointer
	 *
	 * @var object
	 */
	
	private $appCore	= NULL;
	
	/**
	 * Actions White List
	 *
	 * @var array
	 */
	
	private $actions 	= array(
		'index',				'help',				'help',		'login',		'register',
		'activate',				'code_mail',		'rpass',	'user_cp',		'users',
		'user',					'email',			'online'
	);
	
	// ------------------------------------------------------------------------

	/**
	 * Initialise Application
	 *
	 * @param object $appCore
	 */
	
	function __construct( $appCore){
		
		// Store appCore pointer
		$this -> appCore = $appCore;
		
		// Create session handler
		$this -> appCore -> session = new class_session( $appCore);
		
		// Create display handler
		$this -> appCore -> output = new class_output( $appCore);
				
		// Load Commons
		$appCore -> loadLanguageFile( 'commons');
		
		// Forum closed or requires login
		if ( $appCore -> user['id'] < 1 && $appCore -> conf['board_require_login'])
		{
			// Allowed action is Login
			$this -> actions = array( 'login');
		}
		
		// Find if Action Exists?
		if ( in_array( $appCore -> _REQ( 'act'), $this -> actions))
		{
			// Make Action Name
			$action_name = 'action_' . $appCore -> _REQ( 'act');
		}
		else
		{
			// Run First Action from allowed list
			$action_name = 'action_' . $this -> actions[0];
		}
		
		// Run Action
		new $action_name( $appCore);
	}
	
}